import BasicLayout from '@/layouts/basic-layout';
import BasicControl from '@/controls/basic-control';
import powersetting from './modules/powersetting';
import systemsetting from './modules/systemsetting';

/**
 * 在主框架内显示
 */

const frameIn = [
    {
        path: '/',
        redirect: {
            name: 'httpsetting'
        },
        // component: BasicLayout,
        component: BasicControl,
        children: [
            {
                path: 'index',
                name: 'index',
                redirect: {
                    name: 'home'
                }
            },
            {
                path: 'log',
                name: 'log',
                meta: {
                    title: '前端日志',
                    auth: true
                },
                component: () => import('@/pages/system/log')
            },
            // 刷新页面 必须保留
            {
                path: 'refresh',
                name: 'refresh',
                hidden: true,
                component: {
                    beforeRouteEnter (to, from, next) {
                        next(instance => instance.$router.replace(from.fullPath));
                    },
                    render: h => h()
                }
            },
            // 页面重定向 必须保留
            {
                path: 'redirect/:route*',
                name: 'redirect',
                hidden: true,
                component: {
                    beforeRouteEnter (to, from, next) {
                        next(instance => instance.$router.replace(JSON.parse(from.params.route)));
                    },
                    render: h => h()
                }
            },
            {
                path: '/httpsetting',
                name: 'httpsetting',
                meta: {
                    title: '站点列表',
                    auth: true,
                    // keepAlive: true,
                    isCached: true,
                    isBack: true
                },

                component: () => import('@/pages/httpsetting')
            },
            {
                path: '/copytext',
                name: 'copytext',
                meta: {
                    title: '一键复制文章',
                    auth: true,
                    keepAlive: true
                },
                component: () => import('@/pages/copytext')
            },
            {
                path: '/daycount',
                name: 'daycount',
                meta: {
                    title: '日工作量统计',
                    auth: true,
                    keepAlive: true
                },
                component: () => import('@/pages/daycount')
            },
            {
                path: '/robotupload',
                name: 'robotupload',
                meta: {
                    title: '站点上传日志',
                    auth: true,
                    keepAlive: true
                },
                component: () => import('@/pages/robotupload')
            },
            {
                path: '/queueplan',
                name: 'queueplan',
                meta: {
                    title: '队列计划',
                    auth: true,
                    keepAlive: true
                },
                component: () => import('@/pages/queueplan')
            },
            {
                path: '/kingpush',
                name: 'kingpush',
                meta: {
                    title: '收录推送日志',
                    auth: true,
                    keepAlive: true
                },
                component: () => import('@/pages/kingpush')
            },
            {
                path: '/oplog',
                name: 'oplog',
                meta: {
                    title: '操作日志',
                    auth: true,
                    keepAlive: true
                },
                component: () => import('@/pages/oplog')
            },
            {
                path: '/jump',
                name: 'jump',
                meta: {
                    title: '301跳转列表',
                    auth: true,
                    keepAlive: true
                },
                component: () => import('@/pages/jump/index.vue')
            },
            {
                path: '/sourcematerial',
                name: 'sourcematerial',
                meta: {
                    title: '素材库',
                    auth: true,
                    keepAlive: false
                },
                component: () => import('@/pages/sourcematerial/index.vue')
            },

            {
                path: '/demianManagement',
                name: 'demianManagement',
                meta: {
                    title: '域名管理',
                    auth: true,
                    keepAlive: true
                },
                component: () => import('@/pages/demianManagement')
            },
            {
                path: '/home',
                name: 'home',
                meta: {
                    title: '',
                    auth: true
                },
                component: () => import('@/pages/home')
            },
            {
                path: '/business',
                name: 'business',
                meta: {
                    title: '商务通配置',
                    auth: true
                },
                component: () => import('@/pages/business')
            },
            {
                path: '/templatecontrol',
                name: 'templatecontrol',
                meta: {
                    title: '页面模板控制器',
                    auth: true
                },
                component: () => import('@/pages/templatecontrol')
            },
            {
                path: '/pablishAartice',
                name: 'pablishAartice',
                meta: {
                    title: '发布文章',
                    auth: true
                },
                component: () => import('@/pages/release/pablishAartice')
            },
            {
                path: '/articleList',
                name: 'articleList',
                meta: {
                    title: '文章列表',
                    auth: true,
                    isCached: false,
                    isBack: false
                },
                component: () => import('@/pages/release/articleList')
            },
            {
                path: '/badWord',
                name: 'badWord',
                meta: {
                    title: '违禁词列表',
                    auth: true
                },
                component: () => import('@/pages/release/badWord')
            },
            {
                path: '/articleAttr',
                name: 'articleAttr',
                meta: {
                    title: '文章属性配置',
                    auth: true
                },
                component: () => import('@/pages/release/articleAttr')
            },
            {
                path: '/columnList',
                name: 'columnList',
                meta: {
                    title: '文章栏目列表',
                    auth: true
                },
                component: () => import('@/pages/release/columnList')
            },
            {
                path: '/contentSite',
                name: 'contentSite',
                meta: {
                    title: '内容回收站',
                    auth: true
                },
                component: () => import('@/pages/release/contentSite')
            },
            // sqlorder
            {
                path: '/sqlorder',
                name: 'sqlorder',
                meta: {
                    title: 'SQL命令行工具',
                    auth: true
                },
                component: () => import('@/pages/release/sqlorder')
            },
            //basicSite
            {
                path: '/basicSite',
                name: 'basicSite',
                meta: {
                    title: '站点基本配置',
                    auth: true
                },
                component: () => import('@/pages/release/basicSite')
            },
            //公众号页面
            {
                path: '/library',
                name: 'library',
                meta: {
                    title: '公众号素材库',
                    auth: true
                },
                component: () => import('@/pages/public/library')
            },
            {
                path: '/depth',
                name: 'depth',
                meta: {
                    title: '公众号配置',
                    auth: true
                },
                component: () => import('@/pages/public/depth')
            },
            {
                path: '/drafts',
                name: 'drafts',
                meta: {
                    title: '草稿箱',
                    auth: true
                },
                component: () => import('@/pages/public/drafts')
            },
            {
                path: '/newdraftbox',
                name: 'newdraftbox',
                meta: {
                    title: '新建草稿',
                    auth: true
                },
                component: () => import('@/pages/public/newdraftbox')
            },
            {
                path: '/customizemenu',
                name: 'customizemenu',
                meta: {
                    title: '自定义菜单',
                    auth: true
                },
                component: () => import('@/pages/public/customizemenu')
            },
        ]
    },
    // 首页
    // {
    //     path: '/home',
    //     name: 'home',
    //     redirect: {
    //         name: 'home'
    //     },
    //     component: BasicControl,
    //     children: [
    //         {
    //             path: 'home',
    //             name: 'home',
    //             meta: {
    //                 title: '',
    //                 auth: true
    //             },
    //             component: () => import('@/pages/home')
    //         }

    //     ]

    // },

    // 站点管理
    {
        path: '/yewu',
        name: 'yewu',
        meta: {
            title: '',
            auth: true
        },
        component: () => import('@/pages/excessive')
    },
    // 系统设置
    {
        path: '/setting',
        name: 'setting',
        meta: {
            title: '',
            auth: true
        },
        component: () => import('@/pages/excessive')
    },
    // 网页管理
    {
        path: '/report',
        name: 'report',
        meta: {
            title: '',
            auth: true
        },
        component: () => import('@/pages/excessive')
    },
    // 发布系统
    {
        path: '/release',
        name: 'release',
        meta: {
            title: '',
            auth: true
        },
        component: () => import('@/pages/excessive')
    },
    //公众号
    {
        path: '/public',
        name: 'public',
        meta: {
            title: '',
            auth: true
        },
        component: () => import('@/pages/excessive')
    },
    powersetting,
    systemsetting
];

/**
 * 在主框架之外显示
 */

const frameOut = [
    // 登录
    {
        path: '/login',
        name: 'login',
        meta: {
            title: '$t:page.login.title'
        },
        component: () => import('@/pages/account/login')
    },
    // 注册
    {
        path: '/register',
        name: 'register',
        meta: {
            title: '$t:page.register.title'
        },
        component: () => import('@/pages/account/register')
    },
    // 注册结果
    {
        path: '/register/result',
        name: 'register-result',
        meta: {
            auth: true,
            title: '注册结果'
        },
        component: () => import('@/pages/account/register/result')
    }
];

/**
 * 错误页面
 */

const errorPage = [
    {
        path: '/403',
        name: '403',
        meta: {
            title: '403'
        },
        component: () => import('@/pages/system/error/403')
    },
    {
        path: '/500',
        name: '500',
        meta: {
            title: '500'
        },
        component: () => import('@/pages/system/error/500')
    },
    {
        path: '*',
        name: '404',
        meta: {
            title: '404'
        },
        component: () => import('@/pages/system/error/404')
    }
];

// 导出需要显示菜单的
export const frameInRoutes = frameIn;

// 重新组织后导出
export default [
    ...frameIn,
    ...frameOut,
    ...errorPage
];
